﻿#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QWebSocket>
#include <QWebSocketServer>
#include <QtSql>
#include <QNetworkAccessManager>
#include <QNetworkReply>

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

    QWebSocketServer    *m_webSvr;
    QWebSocket          *m_webClient;
    //
    QSqlDatabase    m_db;
    QSqlQuery       *m_dbquery;
    QString         m_szLog;
private slots:
    void onNewConnection();
    void processTextMessage(QString message);
    void processBinaryMessage(QByteArray message);
    void socketDisconnected();
    void closed();

    void on_pushButton_clicked();

private:
    bool jsonobjTobool(QJsonObject obj, const QString &key);
    int jsonobjToint(QJsonObject obj, const QString &key);
    QByteArray jsonobjToByteArray(QJsonObject obj, const QString &key);
    void queryUserServiceCfg(QString &szcmd);
    void saveUserServiceCfg(QJsonObject &obj,QString &szcmd);


    //http测试
    void initNetComm();
    QNetworkAccessManager *m_manager;
private slots:
    void accessManagerFinish(QNetworkReply *reply);
private:
    Ui::MainWindow *ui;
};

#endif // MAINWINDOW_H
